package org.ef.anticheck;

/**
 * 复合 Query，先查本地，再查远程服务器
 * 
 * @author zenglu.liu
 */
public class CompositeQuery implements Query {

	private final Query localQuery;

	private final Query remoteQuery;

	public CompositeQuery(final Query localQuery, final Query remoteQuery) {
		this.localQuery = localQuery;
		this.remoteQuery = remoteQuery;
	}

	public Recoder execute(final String phone) throws QueryException {
		final Recoder r = this.localQuery.execute(phone);
		if (r != null) {
			return r;
		}

		return this.remoteQuery.execute(phone);
	}

	public void dispose() {
		this.localQuery.dispose();
		this.remoteQuery.dispose();
	}
}
